home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / waves-anim.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  3.0 KB  |  105 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; This program is free software; you can redistribute it and/or modify
  4. ; it under the terms of the GNU General Public License as published by
  5. ; the Free Software Foundation; either version 2 of the License, or
  6. ; (at your option) any later version.  
  7. ; This program is distributed in the hope that it will be useful,
  8. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. ; GNU General Public License for more details.
  11. ; You should have received a copy of the GNU General Public License
  12. ; along with this program; if not, write to the Free Software
  13. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. ;
  15. ;
  16. ; waves-anim.scm   version 1.01   1997/12/13
  17. ;
  18. ; CHANGE-LOG:
  19. ; 1.00 - initial release
  20. ; 1.01 - some code cleanup, no real changes
  21. ;
  22. ; Copyright (C) 1997 Sven Neumann <sven@gimp.org>
  23. ;  
  24. ; Makes a copy of your image and creates an animation of the active layer
  25. ; as if a stone was thrown into the image. The animation may be saved with 
  26. ; the gif-plug-in. 
  27.  
  28. (define (script-fu-waves-anim img
  29.                   drawable
  30.                   amplitude
  31.                   wavelength
  32.                   num-frames
  33.                   invert)
  34.   (let* ((amplitude (max 0 amplitude))
  35.      (wavelength (max 0 wavelength))
  36.      (num-frames (max 1 num-frames))
  37.      (remaining-frames num-frames)
  38.      (phase 0)
  39.      (phaseshift (/ 360 num-frames))
  40.          (image (car (gimp-image-duplicate img)))
  41.      (source-layer (car (gimp-image-get-active-layer image))))
  42.    
  43.   (gimp-image-undo-disable image)
  44.  
  45.   (if (= invert TRUE)
  46.       (set! phaseshift (- 0 phaseshift)))
  47.   
  48.   (while (> remaining-frames 1)
  49.      (let* ((waves-layer (car (gimp-layer-copy source-layer TRUE)))
  50.         (layer-name (string-append "Frame "
  51.                        (number->string
  52.                         (- (+ num-frames 2)
  53.                            remaining-frames) 10)
  54.                        " (replace)")))
  55.          (gimp-layer-set-preserve-trans waves-layer FALSE)
  56.      (gimp-image-add-layer image waves-layer -1)
  57.      (gimp-drawable-set-name waves-layer layer-name)
  58.      
  59.      (plug-in-waves 1
  60.             image
  61.             waves-layer
  62.             amplitude
  63.             phase
  64.             wavelength
  65.             0
  66.             FALSE)
  67.       
  68.      (set! remaining-frames (- remaining-frames 1))
  69.      (set! phase (- phase phaseshift))))
  70.  
  71.   (gimp-drawable-set-name source-layer "Frame 1")
  72.   (plug-in-waves 1
  73.          image
  74.          source-layer
  75.          amplitude
  76.          phase
  77.          wavelength
  78.          0
  79.          FALSE)
  80.  
  81.   (gimp-image-undo-enable image)
  82.   (gimp-display-new image)))
  83.  
  84.  
  85. (script-fu-register "script-fu-waves-anim"
  86.             _"_Waves..."
  87.             "Animate an image like a stone's been thrown into it"
  88.             "Sven Neumann <sven@gimp.org>"
  89.             "Sven Neumann"
  90.             "1997/13/12"
  91.             "RGB* GRAY*"
  92.             SF-IMAGE       "Image"            0
  93.             SF-DRAWABLE    "Drawable"         0
  94.             SF-ADJUSTMENT _"Amplitude"        '(10  1  101 1 10 1 0)
  95.             SF-ADJUSTMENT _"Wavelength"       '(10 .10 100 1 10 1 0)
  96.             SF-ADJUSTMENT _"Number of frames" '(6  1   512 1 10 0 1)
  97.             SF-TOGGLE     _"Invert direction" FALSE)
  98.  
  99. (script-fu-menu-register "script-fu-waves-anim"
  100.              _"<Image>/Script-Fu/Animators")
  101.